package moon.core.instruction;

import java.util.List;

import moon.core.entity.RoutineDec;
import moon.core.expression.CallExpr;
import moon.core.expression.Expr;

/** 
 * Call instruction.
 * 
 * @see moon.core.instruction.Instr
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 */
@SuppressWarnings("serial")
public abstract class CallInstr extends Instr {

	/** 
	 * Routine associated to an entity.
	 * 
     * @see moon.core.entity.RoutineDec
     * @see moon.core.entity.Entity
     */    
    private RoutineDec routineDec;
    
    /** 
     * Real arguments.
     */    
    private List<Expr> realArguments;
    
    
    /**
     * Expression to left side.
     */
	private CallExpr leftSide;
	
    /** 
     * Constructor.
     * 
     * @param routineDec routine
     * @param arguments arguments
     * @param line    line
     * @param column  column
     */
    public CallInstr(RoutineDec routineDec, List<Expr> arguments, int line, int column) {
        super(line, column);        
        this.setRoutineDec(routineDec);
        realArguments = arguments;
    }
    
    /** 
     * Sets the routine.
     * 
     * @param pRoutineDec routine
     * @see #getRoutineDec
     */    
    public void setRoutineDec(RoutineDec pRoutineDec) {
        this.routineDec = pRoutineDec;
    }
    
    /** 
     * Gets the routine.
     * 
     * @return routine
     * @see #setRoutineDec
     */    
    public RoutineDec getRoutineDec (){
        return this.routineDec;
    }
    
    /** 
     * Adds a new real argument.
     * 
     * @param pExprAtom real argument
     * @see #getRealArgument
     */    
    public void setRealArgument(Expr pExprAtom){
        this.realArguments.add(pExprAtom);
    }
    
    /** 
     * Gets the real argument in certain position.
     * 
     * @param index index
     * @return real parameter
     * @see #setRealArgument
     */    
    public Expr getRealArgument(int index){
        return realArguments.get(index);
    }   
    
    /**
     * Gets the real argumetns.
     * 
     * @return arguments
     */
    public List<Expr> getRealArguments(){
    	return this.realArguments;
    }
    
    /**
     * Sets the left side.
     * 
     * @param expr expression
     * @see #getLeftSide
     */
	public void setLeftSide(CallExpr expr){
		this.leftSide = expr;
	}
	
	/**
	 * Gets the left side.
	 * 
	 * @return left side or null
	 * @see #setLeftSide
	 * 
	 */
	public CallExpr getLeftSide(){
		return this.leftSide;
	}

    
} // CallInstr
